/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entidades;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author ivana
 */
@Entity
@Table(name = "estadocontrato")
@NamedQueries({
    @NamedQuery(name = "Estadocontrato.findAll", query = "SELECT e FROM Estadocontrato e"),
    @NamedQuery(name = "Estadocontrato.findByIdestadocontrato", query = "SELECT e FROM Estadocontrato e WHERE e.idestadocontrato = :idestadocontrato"),
    @NamedQuery(name = "Estadocontrato.findByNombre", query = "SELECT e FROM Estadocontrato e WHERE e.nombre = :nombre"),
    @NamedQuery(name = "Estadocontrato.findByDescripcion", query = "SELECT e FROM Estadocontrato e WHERE e.descripcion = :descripcion")})
public class Estadocontrato implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idestadocontrato")
    private Integer idestadocontrato;
    @Basic(optional = false)
    @Column(name = "nombre")
    private String nombre;
    @Basic(optional = false)
    @Column(name = "descripcion")
    private String descripcion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "estadocontrato")
    private Collection<Contrato> contratoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "estadocontrato")
    private Collection<Detallecontrato> detallecontratoCollection;

    public Estadocontrato() {
    }

    public Estadocontrato(Integer idestadocontrato) {
        this.idestadocontrato = idestadocontrato;
    }

    public Estadocontrato(Integer idestadocontrato, String nombre, String descripcion) {
        this.idestadocontrato = idestadocontrato;
        this.nombre = nombre;
        this.descripcion = descripcion;
    }

    public Integer getIdestadocontrato() {
        return idestadocontrato;
    }

    public void setIdestadocontrato(Integer idestadocontrato) {
        Integer oldIdestadocontrato = this.idestadocontrato;
        this.idestadocontrato = idestadocontrato;
        changeSupport.firePropertyChange("idestadocontrato", oldIdestadocontrato, idestadocontrato);
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        String oldNombre = this.nombre;
        this.nombre = nombre;
        changeSupport.firePropertyChange("nombre", oldNombre, nombre);
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        String oldDescripcion = this.descripcion;
        this.descripcion = descripcion;
        changeSupport.firePropertyChange("descripcion", oldDescripcion, descripcion);
    }

    public Collection<Contrato> getContratoCollection() {
        return contratoCollection;
    }

    public void setContratoCollection(Collection<Contrato> contratoCollection) {
        this.contratoCollection = contratoCollection;
    }

    public Collection<Detallecontrato> getDetallecontratoCollection() {
        return detallecontratoCollection;
    }

    public void setDetallecontratoCollection(Collection<Detallecontrato> detallecontratoCollection) {
        this.detallecontratoCollection = detallecontratoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idestadocontrato != null ? idestadocontrato.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Estadocontrato)) {
            return false;
        }
        Estadocontrato other = (Estadocontrato) object;
        if ((this.idestadocontrato == null && other.idestadocontrato != null) || (this.idestadocontrato != null && !this.idestadocontrato.equals(other.idestadocontrato))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Estadocontrato[idestadocontrato=" + idestadocontrato + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
